"""
URL configuration for server project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, re_path, include
from django.views.static import serve
from server.settings import MEDIA_ROOT
import time

from django.conf import settings

from ez_android_automator.client import create_usb_client,create_network_client
from ez_android_automator.manager import Manager
from django.conf import settings
# import requests
# from apscheduler.scheduler import Scheduler


# # 启动manager
manager = Manager()
client = create_usb_client()
# client = create_network_client('192.168.3.166:5555')
manager.add_client(client)
#
# manager.add_client(client)
manager.start()

# sched = Scheduler()
#
# @sched.interval_schedule(seconds=10)
# def my_task():
#     # 这里写入你想要访问的API地址及参数等相关信息
#
#     try:
#         requests.get('http://' + settings.REQUEST_IP + ':8000/medias/task/device_task/')
#     except Exception as exception :
#         print('http service is not start')
#     pass
#
# sched.start()



urlpatterns = [
    path('admin/', admin.site.urls),

    # API User
    path('user/', include('app.user.urls')),

    # API System
    path('system/', include('app.system.urls')),

    # API Company
    path('company/', include('app.company.urls')),

    # API Platefrom
    path('platefrom/', include('app.platefrom.urls')),

    # API Medias
    path('medias/', include('app.medias.urls')),

    # API Home
    path('home/', include('app.home.urls')),


    # 媒体文件
    re_path('^media/(?P<path>.*)$', serve, {'document_root': MEDIA_ROOT}),


]


